<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/themes/icon.css" />

<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
	$(function() {
		$("#win").window("close");
		$.ajax({
			type : 'post',
			url : '${pageContext.request.contextPath}/showUserInfoAction',
			dataType : 'json',
			success : function(data) {
				$("#infoTable").append(
						"<tr style='display:none;'><td>餐厅id</td><td>"
								+ data.sid + "</td><tr>"
								+ "<tr><td >餐厅名</td><td id='sname'>"
								+ data.sname + "</td><tr>"
								+ "<tr><td >餐厅地址</td><td id='saddress'>"
								+ data.saddress + "</td></tr>"
								+ "<tr><td >餐厅注册时间</td><td id='screatetime' name='screatetime'>"
								+ data.screatetime + "</td></tr>"
								+ "<tr><td >餐厅电话</td><td id='sphone'>"
								+ data.sphone + "</td></tr>"
								+ "<tr><td >餐厅邮箱</td><td id='semail'>"
								+ data.semail + "</td></tr>");
			}
		});
		
		
		$("#editsinfobt").click(function() {
			
			$("#win").window("open");
			
			var sname = $("#sname").text();			
			var sphone = $("#sphone").text();
			var saddress = $("#saddress").text();
			var screatetime = $("#screatetime").text();		
			var semail = $("#semail").text();
		
			$("#editsname").textbox("setValue",sname);
			$("#editsphone").textbox("setValue",sphone);
			$("#editsaddress").textbox("setValue",saddress);
			$("#editsemail").textbox("setValue",semail);
			$("#editscreatetime").textbox("setValue",screatetime);
		})

		$("#cancel").click(function() {
			$("#editinfoTable").hide();
			$("#infoTable").show();
			$("#editaction").hide();
			$("#cancel").hide();
			$("#editsinfo").show();
		})
		//验证
		$.extend($.fn.validatebox.defaults.rules, {    
			   
			
			 Number: {  
			        validator: function (value) {  
			            var reg =/^[0-9]*$/;  
			            return reg.test(value);  
			        },  
			        message: '请输入数字'  
			    }, 
			    
			    phone: {  
			        validator: function (value) {  
			            var reg = /^[0-9]\d{10}$/;  
			            return reg.test(value);  
			        },  
			        message: '电话号码必须为11位'  
			    },
			     
			});  
			
	
	});
	function submitForm(){
		$("#editinfoTable").form('submit', {    
		    url:'${pageContext.request.contextPath}/editsinfoAction',      
		    success:function(data){  
		    	
		        if(data==1){
		        	$.messager.alert('提示','修改成功');  
		        	$("#win").window("close");
		        	$('#editinfoTable').form('clear');
		        	location.href="sinfo.jsp"
		        }else{
						$.messager.alert('提示','修改失败',"error",function(){	
					}); 
		        }   
		    }    
		});
    }
	function clearForm(){
		$('#editinfoTable').form('clear')
	}
	
</script>
<body>
	<div class="container-fluid">
		<div class="row">
			<div class="col-md-8 col-md-offset-2" style="margin-top: 50px">
				<table id="infoTable" class="table table-striped">
				<button id ="editsinfobt" >修改信息</button>
				<br>
				</table>
				<div   id="editsinfoDiv" style = "dsplay:none">
				 <div id="win" class="easyui-window" title="个人信息修改" style="width:400px;height:480px"   
        data-options="collapsible:false,minimizable:false,maximizable:false,draggable:false,resizable:false,modal:true" >   
        				<div style="margin:10px 0;"></div>
        				<div >
        <form id="editinfoTable"  method="post" >                            
            <div style="margin-bottom:5px">
            <label>餐厅名</label>
                <input class="easyui-textbox" type="text" id="editsname" name="editsname" style="width:100%" data-options="required:true">
            </div>
            <div style="margin-bottom:5px">
           <label>餐厅地址</label>
                <input class="easyui-textbox" id="editsaddress" name="editsaddress" style="width:100%" data-options="required:true" >
            </div>
             
            <div style="margin-bottom:5px">
           <label>电话</label>
                <input class="easyui-textbox" id="editsphone"  name="editsphone" style="width:100%" data-options="required:true,validType:'phone'">
            </div>
             <div style="margin-bottom:5px">
           
           <label>邮箱</label>
                <input class="easyui-textbox" id="editsemail" name="editsemail" style="width:100%" data-options="required:true,validType:'email'">
            </div>
           
            <div style="text-align:center;padding:5px ">
            <a id="qd" href="javascript:void(0)" class="easyui-linkbutton btn btn-default btn-sm" onclick="submitForm()" style="width:80px">确定</a>
       <a id="clearBtn" href="javascript:void(0)" class="easyui-linkbutton btn btn-default btn-sm" onclick="clearForm()" style="width:80px">清空</a>
        </div>
        </form>
        </div>
					</div>  
				</div>
			</div>
		</div>
	</div>
</body>
</html>